#include <iostream>
using namespace std;
#include <queue>
#include <vector>

class Point
{
public:
    Point(int x, inty) : m_x(x), m_y(y) {};

public:
    void display()
    {
        cout << "(" << m_x << "," << m_y << ")" << endl;
    }

public:
    int m_x;
    int m_y;
};

struct mycompare
{
    bool operator()(Point a, Point b)
    {
        /*a:代表父节点比较元素*/
        /*b:代表当前节点比较元素*/
        return (a.m_x * a.m_x + a.m_y * a.m_y) < (b.m_x * b.m_x + b.m_y * b.m_y);
    }
};

int main()
{
#if 0
    /*队列*/
    queue<int> myqueue;

    /*入队*/
    myqueue.push(13);
    myqueue.push(45);
    myqueue.push(11);
    myqueue.push(9);
    myqueue.push(32);

    /*队列的元素个数 */
    cout << "size:" << myqueue.size() << endl;

    /*队头元素 */
    cout << "front:" << myqueue.front() << endl;
    /*队尾元素*/
    cout << "back:" << myqueue.back() << endl;

    myqueue.pop();
#endif

#if 0
    /*优先级队列-堆（默认是大顶堆）*/
    priority_queue<int> myheap;

    /*入队*/
    myheap.push(134);
    myheap.push(66);
    myheap.push(55);
    myheap.push(13);
    myheap.push(9);
    myheap.push(27);

    /*优先级队列的元素个数*/
    cout << "size:" << myheap.size() << endl;

    /*堆顶元素*/
    cout << "top:" << myheap.top() << endl;

    /*弹出堆顶元素*/
    myheap.pop();

    /*堆顶元素*/
    cout << "top:" << myheap.top() << endl;

#endif

#if 0
    // 如何构建小顶堆
    priority_queue<int, vector<int>, mycompare> myheap2;

    /*队列 */
    myheap2.push(31);
    myheap2.push(23);
    myheap2.push(145);
    myheap2.push(99);
    myheap2.push(78);

    /*查看堆顶元素*/
    cout << "top:" << myheap2.top() << endl;

#endif

#if 0

    Point p1(3, 4);
    Point p2(2, 7);
    Point p3(6, 3);
    Point p4(5, 2);
    Point p5(4, 3);
    priority_queue<Point, vector<Point>, mycompare> myheap4;
    myheap4.push(p1);
    myheap4.push(p2);
    myheap4.push(p3);
    myheap4.push(p4);
    myheap4.push(p5);

    /*取出堆顶元素*/
    myheap4.top().display();
#endif

#if 1
    vector<int> myvec;

    myvec.push_back(11);
    myvec.push_back(22);
    myvec.push_back(33);
    myvec.push_back(44);
    myvec.push_back(55);

    /*迭代器->迭代器就是指针 */
    for (vector<int>::iterator iter = myvec.begin(); iter !=myvec.end(); iter++)
    {
        cout << *iter << endl;
    }

#endif
}
